<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>main</title>
<jsp:include page="../../pages/head.jsp" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/js/jquery.combogrid/resources/css/smoothness/jquery-ui-1.10.1.custom.css"/>
<script type="text/javascript" src="<%=path %>/js/jquery.combogrid/resources/jquery/jquery-ui-1.10.1.custom.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/js/jquery.combogrid/resources/css/smoothness/jquery.ui.combogrid.css"/>
<script type="text/javascript" src="<%=path %>/js/jquery.combogrid/resources/plugin/jquery.ui.combogrid-1.6.3.js"></script>
<script type="text/javascript">
	function save(){
		if (!checkForm(document.getElementById("saveForm"))) {
			return;
		}
		xbox.load("loading");	
		$("#saveForm").ajaxSubmit({
	 	  		
	 	  	success: function(data){
			    if(data==null){
					xbox.ready("loading");
					var input = $("#clientName");
					addError(input,'客户名称:"'+input.val()+'"已经存在,请重新输入.');
				}
				else
		 	  		$("#refreshForm").submit();
		     },
		     error:function(){
		    	 xbox.ready("loading");
		    	 j_tip("保存数据超时或网络问题,请尝试重新登录.","error");
		     }
	    });
	}
	function turnBack(){
		xbox.load("loading");
	   $("#refreshForm").submit();
	}
	$(function(){
		$( "#areaName" ).combogrid({
			url: '<%=path%>/area/areaAjax_query4AutoComplete_resourceAction.action',
			debug:false,
	    	//replaceNull: true,
			colModel: [{'columnName':'areaId','width':'15','label':'编号'}, {'columnName':'areaName','width':'40','label':'办事处名称'}],
			select: function( event, ui ) {
				$("#areaName").val(ui.item.areaName);
				$("#areaId").val(ui.item.areaId);
				return false;
			},
			inputSpace:function(){
				$("#areaId").val("");
			}
		});
		$( "#clientLevelName" ).combogrid({
			url: '<%=path%>/clientLevel/clientLevelAjax_query4AutoComplete_resourceAction.action',
			debug:false,
	    	//replaceNull: true,
			colModel: [{'columnName':'clientLevelId','width':'15','label':'编号'}, {'columnName':'clientLevelName','width':'40','label':'办事处名称'}],
			select: function( event, ui ) {
				$("#clientLevelName").val(ui.item.clientLevelName);
				$("#clientLevelId").val(ui.item.clientLevelId);
				return false;
			},
			inputSpace:function(){
				$("#clientLevelId").val("");
			}
		});
		$( "#clientTypeName" ).combogrid({
			url: '<%=path%>/clienttype/clienttypeAjax_query4AutoComplete_resourceAction.action',
			debug:false,
	    	//replaceNull: true,
			colModel: [{'columnName':'clientTypeId','width':'15','label':'编号'}, {'columnName':'clientTypeName','width':'40','label':'办事处名称'}],
			select: function( event, ui ) {
				$("#clientTypeName").val(ui.item.clientTypeName);
				$("#clientTypeId").val(ui.item.clientTypeId);
				return false;
			},
			inputSpace:function(){
				$("#clientTypeId").val("");
			}
		});
	});

</script>

</head>
<body>
<form action="<%=path%>/client/clientAjax_save_msgAction.action" method="post" id="saveForm">
<table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#F1F1F1" style="margin-bottom:8px">
  <tr bgcolor="#FFFFFF">
    <td colspan="4" height="16"><span></span></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>客户名称：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input maxlength="25" type="text" name="client.clientName" id="clientName" isNull="客户名称" value="${client.clientName}" />
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>所属办事处：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
    			<input maxlength="25" type="hidden" name="client.area.areaId" id="areaId" value="${client.area.areaId}" />
    			<input maxlength="25" type="text" name="client.area.areaName" id="areaName" isNull="所属办事处" value="${client.area.areaName}" />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>客户级别：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
              <input maxlength="25" type="hidden" name="client.clientLevel.clientLevelId" id="clientLevelId" value="${client.clientLevel.clientLevelId}" />
    		  <input maxlength="25" type="text" name="client.clientLevel.clientLevelName" id="clientLevelName" isNull="客户级别" value="${client.clientLevel.clientLevelName}" />
    </td>
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>客户类型：</td>
    <td width="40%" align="left" bgcolor="#FFFFFF">
    			<input maxlength="25" type="hidden" name="client.clientType.clientTypeId" id="clientTypeId" value="${client.clientType.clientTypeId}" />
    			<input maxlength="25" type="text" name="client.clientType.clientTypeName" id="clientTypeName" isNull="客户类型" value="${client.clientType.clientTypeName}" />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>客户简介：</td>
    <td width="90%" align="left" bgcolor="#FFFFFF" colspan="3">
              <input maxlength="25" type="text" name="client.clientDesc" id="clientDesc" isNull="客户简介" value="${client.clientDesc}" />
    </td>
  </tr>
  <tr align="right" bgcolor="#F1F1F1">
	<td height="36" colspan="4" align="center">
		<input type='button' class="btn btn-primary" id="btnSave" onclick="save();" value='保存' />
	    &nbsp;<input type='button' class="btn" onclick="turnBack();" value='返回' />
</td>
</tr>
</table>
</form>

<form action="${listUrl}" method="post" style="display: none;" id="refreshForm" name="refreshForm"/>

</body>
</html>
